import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import naive from 'naive-ui'
import { createDiscreteApi } from 'naive-ui'
import { router } from './common/router'
import { createPinia } from "pinia";
import axios from 'axios'
import { AdminStore } from './stores/AdminStore'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css' // 引入 Element UI 样式

// 服务端地址 正式环境
// axios.defaults.baseURL = "http://52.77.218.83:5294"
// axios.defaults.baseURL = "http://localhost:5294"
// axios.defaults.baseURL = "http://localhost"
axios.defaults.baseURL = "http://testweb.zhusiot.com"
//Vue.prototype.$http = axios;
// createApp.prototype.$http=axios;
//
// src/main.js
import "./css/tailwindcss.css"
// import signalr from './utils/signalR'
// Vue.use(signalr)

createApp(App).mount('#app')

// 独立API
const { message, notification, dialog } = createDiscreteApi(["message", "dialog", "notification"])

const app = createApp(App)

// 全局提供属性
app.provide("axios", axios)
app.provide("message", message)
app.provide("notification", notification)
app.provide("dialog", dialog)
app.provide("server_url", axios.defaults.baseURL)

app.use(naive)
app.use(ElementPlus) // 使用 Element UI
app.use(createPinia())
app.use(router)

const adminStore = AdminStore()

// axios拦截器
axios.interceptors.request.use((config) => {
    // 每次请求都在 headers 中添加 token
    config.headers.token = adminStore.token
    return config
})

// app.config.globalProperties.$signalr = signalr.signal;

app.mount('#app')

